Skip to content

feat(nodemetadataenricher): Add log signal support#2095

Open
miconeilaws wants to merge 4 commits into
mainfrom
miconeil/nodemetadataenricher-log-support
Open

feat(nodemetadataenricher): Add log signal support#2095
miconeilaws wants to merge 4 commits into
mainfrom
miconeil/nodemetadataenricher-log-support

Conversation

@miconeilaws

Copy link
Copy Markdown
Collaborator

Extend the nodemetadataenricher processor to handle logs in addition to metrics. The processLogs method uses the same logic as processMetrics: looks up k8s.node.name in resource attributes and stamps host.id, host.name, host.type, host.image.id, and cloud.availability_zone from the Lease-based node metadata cache.

This enables the cluster-scraper's K8s events pipeline to enrich event logs with per-node IMDS metadata.

@miconeilaws miconeilaws requested a review from a team as a code owner April 21, 2026 09:21
@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity.

@github-actions github-actions Bot added the Stale label Apr 30, 2026
@louisall louisall force-pushed the miconeil/nodemetadataenricher-log-support branch 2 times, most recently from 9601128 to 3883567 Compare May 18, 2026 12:15
@github-actions github-actions Bot removed the Stale label May 19, 2026
sky333999
sky333999 previously approved these changes May 19, 2026
@louisall louisall force-pushed the miconeil/nodemetadataenricher-log-support branch from 3883567 to ad561a8 Compare May 19, 2026 08:32
@louisall louisall added the ready for testing Indicates this PR is ready for integration tests to run label May 19, 2026
Comment thread plugins/processors/nodemetadataenricher/processor.go
louisall added a commit that referenced this pull request May 20, 2026
Mirror the existing metrics tests on the logs path so processLogs has
direct unit coverage. Adds a createTestLogs helper and 7 mirror tests
for cache hit, cache miss, missing/empty node name, log count
preservation, AZ overwrite, and mixed input handling.

Also adds TestLazyInitLogsCache, which exercises the only branch in
processLogs whose behavior diverges across calls — cache nil at
construction, populated before first invocation. Verifies the
processor lazy-loads the cache, stores the reference, and continues
to enrich on subsequent calls even after the singleton is cleared.

Addresses sky333999's review feedback on PR #2095.
@louisall

Copy link
Copy Markdown
Collaborator

4 failing checks are unrelated:

sles-15:ca_bundle_test fails on both amd64 and arm64 (showing as 2 reds). The matrix hardcodes caCertPath: /etc/ssl/certs/ca-bundle.crt, which doesn't exist on SLES 15 — SUSE puts it at /etc/ssl/ca-bundle.pem. Fails on every PR
that runs the SLES tests.

rocky-linux-9:ssm_document_test is a 5-minute SSM-ready timeout — the EC2 instance didn't register with Systems Manager in time. Same flake has hit several recent unrelated PRs.

Verify All PR Test Jobs is the workflow aggregator and just rolls up the 3 above.

louisall added a commit that referenced this pull request May 27, 2026
Mirror the existing metrics tests on the logs path so processLogs has
direct unit coverage. Adds a createTestLogs helper and 7 mirror tests
for cache hit, cache miss, missing/empty node name, log count
preservation, AZ overwrite, and mixed input handling.

Also adds TestLazyInitLogsCache, which exercises the only branch in
processLogs whose behavior diverges across calls — cache nil at
construction, populated before first invocation. Verifies the
processor lazy-loads the cache, stores the reference, and continues
to enrich on subsequent calls even after the singleton is cleared.

Addresses sky333999's review feedback on PR #2095.
@louisall louisall force-pushed the miconeil/nodemetadataenricher-log-support branch from eff009b to 13fa009 Compare May 27, 2026 11:28
miconeilaws and others added 2 commits May 28, 2026 11:24
Extend the nodemetadataenricher processor to handle logs in addition to
metrics. The processLogs method uses the same logic as processMetrics:
looks up k8s.node.name in resource attributes and stamps host.id,
host.name, host.type, host.image.id, and cloud.availability_zone from
the Lease-based node metadata cache.

This enables the cluster-scraper's K8s events pipeline to enrich event
logs with per-node IMDS metadata.
Mirror the existing metrics tests on the logs path so processLogs has
direct unit coverage. Adds a createTestLogs helper and 7 mirror tests
for cache hit, cache miss, missing/empty node name, log count
preservation, AZ overwrite, and mixed input handling.

Also adds TestLazyInitLogsCache, which exercises the only branch in
processLogs whose behavior diverges across calls — cache nil at
construction, populated before first invocation. Verifies the
processor lazy-loads the cache, stores the reference, and continues
to enrich on subsequent calls even after the singleton is cleared.

Addresses sky333999's review feedback on PR #2095.
@louisall louisall force-pushed the miconeil/nodemetadataenricher-log-support branch from 13fa009 to 13c8e83 Compare May 28, 2026 12:11
movence
movence previously approved these changes Jun 4, 2026
)
}

func createLogsProcessor(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing unit tests for this function and maybe this file as well

return md, nil
}

func (p *nodeMetadataEnricherProcessor) processLogs(_ context.Context, ld plog.Logs) (plog.Logs, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like this is an almost duplicate of processMetrics, can we extract the common functionality into a util function and use it inside both processing functions ?

… add factory tests

processMetrics and processLogs were near-byte-identical, with the same
lazy-init prelude and the same per-resource enrichment loop body. Extract
both into helpers:

- resolveCache() — handles the cache.Load + lazy-init pattern, returning
  nil when the extension is still unavailable.
- enrichResource(pcommon.Resource, *NodeMetadataCache) — performs the
  node-name lookup and writes the 5 host attributes. Operates on the
  signal-agnostic pcommon.Resource type so both pipelines reuse it.

processMetrics and processLogs become ~6 lines each — cache resolve +
slice walk. Public API unchanged; all 17 existing unit tests pass through
the refactored code path.

Also adds factory_test.go covering NewFactory, createDefaultConfig, and
both createMetricsProcessor and createLogsProcessor (including their
configuration-type assertion error branches).

Addresses mitali-salvi's review feedback on PR #2095.
@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity.

@github-actions github-actions Bot added the Stale label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for testing Indicates this PR is ready for integration tests to run Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants